<?php
	session_start();
	require_once('common/config.php');

	if(!defined('BASE_DIR'))
	  define('BASE_DIR', $_SERVER['DOCUMENT_ROOT']) ;
	
	if(!isset($_GET['type']))
	{
		if(!isset($_SESSION['logon']))
		{
			header("Location: /wks/login.php?url=slider");
			exit();
		}
		
		
		  
		$pageCMS = PAGE_CMS_SLIDER;
		$slider = simplexml_load_file(BASE_DIR."/xml/homepage_banner.xml");
		
		if(!isset($_POST['submit'])){
			require_once('template/banner/homebanner_view.php');
			exit();
		}
		else
		{
			$slider->banner1->link = $_POST['slider_link1'] != ''?$_POST['slider_link1'] : '#';
			$slider->banner1->image = $_POST['slider_img1'];
			
			$slider->banner2->link = $_POST['slider_link2'] != ''?$_POST['slider_link2'] : '#';
			$slider->banner2->image = $_POST['slider_img2'];
			
			$slider->banner3->link = $_POST['slider_link3'] != ''?$_POST['slider_link3'] : '#';
			$slider->banner3->image = $_POST['slider_img3'];
			
			$slider->banner4->link = $_POST['slider_link4'] != ''?$_POST['slider_link4'] : '#';
			$slider->banner4->image = $_POST['slider_img4'];
			
			$slider->asXML(BASE_DIR."/xml/homepage_banner.xml");
			header("Location: /wks/slider.php");
		}
	}
	if(isset($_GET['type']) && $_GET['type']=='bottom')
	{
		if(!isset($_SESSION['logon']))
		{
			header("Location: /wks/login.php?url=slider");
			exit();
		}
		
		$pageCMS = PAGE_CMS_BOTTOM_BANNER;
		$slider = simplexml_load_file(BASE_DIR."/xml/homepage_bottom_banner.xml");
		
		if(!isset($_POST['submit'])){
			require_once('template/banner/home_bottom_banner_view.php');
			exit();
		}
		else
		{
			$slider->banner1->link = $_POST['slider_link1'] != ''?$_POST['slider_link1'] : '#';
			$slider->banner1->image = $_POST['slider_img1'];
			$slider->banner1->title = $_POST['slider_title1'];
			
			$slider->banner2->link = $_POST['slider_link2'] != ''?$_POST['slider_link2'] : '#';
			$slider->banner2->image = $_POST['slider_img2'];
			$slider->banner2->title = $_POST['slider_title2'];
			
			$slider->banner3->link = $_POST['slider_link3'] != ''?$_POST['slider_link3'] : '#';
			$slider->banner3->image = $_POST['slider_img3'];
			$slider->banner3->title = $_POST['slider_title3'];
			
			$slider->banner4->link = $_POST['slider_link4'] != ''?$_POST['slider_link4'] : '#';
			$slider->banner4->image = $_POST['slider_img4'];
			$slider->banner4->title = $_POST['slider_title4'];
			
			$slider->asXML(BASE_DIR."/xml/homepage_bottom_banner.xml");
			header("Location: /wks/slider.php?type=bottom");
		}
	}
?>


